home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIPrincipal.idl < prev    next >
Text File  |  2006-05-08  |  9KB  |  207 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1999-2003
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Mitchell Stoltz <mstoltz@netscape.com>
  24.  *   Christopher A. Aillon <christopher@aillon.com>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  28.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. /* Defines the abstract interface for a principal. */
  41.  
  42. #include "nsISerializable.idl"
  43.  
  44. %{C++
  45. struct JSContext;
  46. struct JSPrincipals;
  47. %}
  48.  
  49. interface nsIURI;
  50.  
  51. [ptr] native JSContext(JSContext);
  52. [ptr] native JSPrincipals(JSPrincipals);
  53.  
  54. [uuid(fb9ddeb9-26f9-46b8-85d5-3978aaee05aa)]
  55. interface nsIPrincipal : nsISerializable
  56. {
  57.     /**
  58.      * Values of capabilities for each principal. Order is
  59.      * significant: if an operation is performed on a set
  60.      * of capabilities, the minimum is computed.
  61.      */
  62.     const short ENABLE_DENIED                = 1;
  63.     const short ENABLE_UNKNOWN               = 2;
  64.     const short ENABLE_WITH_USER_PERMISSION  = 3;
  65.     const short ENABLE_GRANTED               = 4;
  66.  
  67.     /**
  68.      * Returns the security preferences associated with this principal.
  69.      * prefBranch will be set to the pref branch to which these preferences
  70.      * pertain.  id is a pseudo-unique identifier, pertaining to either the
  71.      * fingerprint or the origin.  subjectName is a name that identifies the
  72.      * entity this principal represents (may be empty).  grantedList and
  73.      * deniedList are space-separated lists of capabilities which were
  74.      * explicitly granted or denied by a pref.
  75.      */
  76.     void getPreferences(out string prefBranch, out string id,
  77.                         out string subjectName,
  78.                         out string grantedList, out string deniedList);
  79.  
  80.     /**
  81.      * Returns whether the other principal is equivalent to this principal.
  82.      * Principals are considered equal if they are the same principal,
  83.      * they have the same origin, or have the same certificate fingerprint ID
  84.      */
  85.     boolean equals(in nsIPrincipal other);
  86.  
  87.     /**
  88.      * Returns a hash value for the principal.
  89.      */
  90.     readonly attribute unsigned long hashValue;
  91.  
  92.     /**
  93.      * Returns the JS equivalent of the principal.
  94.      * @see JSPrincipals.h
  95.      */
  96.     JSPrincipals getJSPrincipals(in JSContext cx);
  97.  
  98.     /**
  99.      * The domain security policy of the principal.
  100.      */
  101.     // XXXcaa should this be here?  The script security manager is the only
  102.     // thing that should care about this.  Wouldn't storing this data in one
  103.     // of the hashtables in nsScriptSecurityManager be better?
  104.     // XXXbz why is this writable?  Who should have write access to this?  What
  105.     // happens if this principal is in our hashtable and we pass it out of the
  106.     // security manager and someone writes to this field?  Especially if they
  107.     // write garbage?  If we need to give someone other than the security
  108.     // manager a way to set this (which I question, since it can increase the
  109.     // permissions of a page) it should be a |void clearSecurityPolicy()|
  110.     // method.
  111.     attribute voidPtr securityPolicy;
  112.  
  113.     // XXXcaa probably should be turned into {get|set}CapabilityFlags
  114.     // XXXbz again, what if this lives in our hashtable and someone
  115.     // messes with it?  Is that OK?
  116.     short canEnableCapability(in string capability);
  117.     void setCanEnableCapability(in string capability, in short canEnable);
  118.     boolean isCapabilityEnabled(in string capability, in voidPtr annotation);
  119.     void enableCapability(in string capability, inout voidPtr annotation);
  120.     void revertCapability(in string capability, inout voidPtr annotation);
  121.     void disableCapability(in string capability, inout voidPtr annotation);
  122.  
  123.     /**
  124.      * The codebase URI to which this principal pertains.  This is
  125.      * generally the document URI.
  126.      */
  127.     readonly attribute nsIURI URI;
  128.  
  129.     /**
  130.      * The domain URI to which this principal pertains.
  131.      * This is congruent with HTMLDocument.domain, and may be null.
  132.      * Setting this has no effect on the URI.
  133.      */
  134.     attribute nsIURI domain;
  135.  
  136.     /**
  137.      * The origin of this principal's domain, if non-null, or its
  138.      * codebase URI otherwise. An origin is defined as:
  139.      * scheme + host + port.
  140.      */
  141.     // XXXcaa this should probably be turned into an nsIURI.
  142.     // The system principal's origin should be some caps namespace
  143.     // with a chrome URI.  All of chrome should probably be the same.
  144.     readonly attribute string origin;
  145.  
  146.     /**
  147.      * Whether this principal is associated with a certificate.
  148.      */
  149.     readonly attribute boolean hasCertificate;
  150.  
  151.     /**
  152.      * The fingerprint ID of this principal's certificate.
  153.      * Throws if there is no certificate associated with this principal.
  154.      */
  155.     // XXXcaa kaie says this may not be unique.  We should probably
  156.     // consider using something else for this....
  157.     readonly attribute AUTF8String fingerprint;
  158.  
  159.     /**
  160.      * The pretty name for the certificate.  This sort of (but not really)
  161.      * identifies the subject of the certificate (the entity that stands behind
  162.      * the certificate).  Note that this may be empty; prefer to get the
  163.      * certificate itself and get this information from it, since that may
  164.      * provide more information.
  165.      *
  166.      * Throws if there is no certificate associated with this principal.
  167.      */
  168.     readonly attribute AUTF8String prettyName;
  169.  
  170.     /**
  171.      * Returns whether the other principal is equal to or weaker than this
  172.      * principal.  Principals are equal if they are the same object, they
  173.      * have the same origin, or they have the same certificate ID.
  174.      *
  175.      * Thus a principal subsumes itself if it is equal to itself.
  176.      *
  177.      * The system principal subsumes itself and all other principals except
  178.      * the non-principal.
  179.      *
  180.      * The non-principal is not equal to itself or any other principal, and
  181.      * therefore does not subsume itself.
  182.      *
  183.      * Both codebase and certificate principals are subsumed by the system
  184.      * principal, but no codebase or certificate principal yet subsumes any
  185.      * other codebase or certificate principal.  This may change in a future
  186.      * release; note that nsIPrincipal is unfrozen, not slated to be frozen.
  187.      */
  188.     boolean subsumes(in nsIPrincipal other);
  189.  
  190.     /**
  191.      * The subject name for the certificate.  This actually identifies the
  192.      * subject of the certificate.  This may well not be a string that would
  193.      * mean much to a typical user on its own (e.g. it may have a number of
  194.      * different names all concatenated together with some information on what
  195.      * they mean in between).
  196.      *
  197.      * Throws if there is no certificate associated with this principal.
  198.      */
  199.     readonly attribute AUTF8String subjectName;
  200.  
  201.     /**
  202.      * The certificate associated with this principal, if any.  If there isn't
  203.      * one, this will return null.  Getting this attribute never throws.
  204.      */
  205.     readonly attribute nsISupports certificate;
  206. };
  207.